function submitOnlinePay(valp,valn){

		if(valp == 'fq81RK7q5ApY867'){//支付宝
		document.getElementById(valn).action="/program/jsalipay/index.jsp";
		}else if(valp == '2740x430vJO7V8H'){//网银在线
		document.getElementById(valn).action="/program/chinabank/Send.jsp";
		}else{
		alert("您没有选择在线支付方式!");
		return false;
		}
}

function trim(str)
{
    return str.replace(/(^\s*)|(\s*$)/g,"");
}

function getOneOrderState(val)
{
   
   //alert(val);   
    //--1 
    if(val.indexOf('a')>-1)
    {
      return '0';
    }
    
    var or_state = val.split('|');    
    
    //--2
    var var_b=''; 
    for(var i=0;i<or_state.length;i++)
    {
         var o_s_b = or_state[i];	       
	       if(o_s_b.indexOf('b')>-1)
	       {
	         var_b +='0';       
	       }
	       else if(o_s_b.indexOf('c')>-1 || o_s_b.indexOf('d')>-1)	       
	       {
           var_b +='1';           	       
	       }
	       else
	       {
           var_b +='2'; 	       
	       }    
    }    
    
    if((var_b.indexOf('2')==-1) && (var_b.indexOf('0')>-1))
    {
       return '1';    
    }
   
    //--3
    var var_c=''; 
    for(var i=0;i<or_state.length;i++)
    {
	       if(or_state[i].indexOf('c')>-1)
	       {
	         var_c +='0';       
	       }
	       else
	       {
           var_c +='1'; 	       
	       }    
    }    
    
    if((var_c.indexOf('1')==-1) && (var_c.indexOf('0')>-1))
    {
       return '2';    
    }
    
    //--4    
    var var_d=''; 
    
    for(var i=0;i<or_state.length;i++)
    {
         var o_s_d = or_state[i];	       
	       if(o_s_d.indexOf('d')>-1)
	       {
	         var_d +='0';       
	       }
         else if(o_s_d.indexOf('c')>-1)
         {
           var_d +='1';          
         }	       
	       else
	       {
           var_d +='2'; 	       
	       }    
    }    
    
    if((var_d.indexOf('2')==-1) && (var_d.indexOf('0')>-1))
    {
       return '3';    
    }
    
     //--5    
    var var_m=''; 
    for(var i=0;i<or_state.length;i++)
    {
         var o_s_m = or_state[i];	       
	       if(o_s_m.indexOf('m')>-1)
	       {
	         var_m +='0';       
	       }
	       else if(o_s_m.indexOf('c')>-1 || o_s_m.indexOf('d')>-1)	       
	       {
           var_m +='1';           	       
	       }
	       else
	       {
           var_m +='2'; 	       
	       }    
    }    
    
    if((var_m.indexOf('2')==-1) && (var_m.indexOf('0')>-1))
    {
       return '5';    
    }
       	  
 	  return  '4';	
} 


function getStateName(val)
{
    if(val=='0'){return '未确认';}
    else if(val=='1'){return '已确认';}
    else if(val=='2'){return '取消';}
    else if(val=='3'){return '无效';}
    else if(val=='4'){return '交易中';} 
    else if(val=='5'){return '交易完成';} 
 } 


function receiving(val1,val2)
{
	
	 var opr_state = document.getElementById('state_'+val1+'_'+val2).value;  
	 opr_state =	opr_state.replace('g',''); 
	 opr_state ='h'+opr_state; 
	 
	 var one_check = document.getElementById('check_'+val1+'_'+val2).value;	 
	 var trade_id_state = one_check+'|'+opr_state+',';	
   var trade_id_oprstate = one_check+'|h|收货确认,';  
   
   var all_state=opr_state+'|';
   
   var onesize = document.getElementById('checksize_'+val1).value; 
   for(var i=0;i<onesize;i++)
   { 
   	     
   	   if(i!=val2)
   	   {
   	     all_state +=  document.getElementById('state_'+val1+'_'+i).value+'|'; 
   	   
   	   }       
   
   }  
  
    var o_state = getOneOrderState(all_state);
    var checkone = document.getElementById('checkone_'+val1).value;	             
    var order_id_state = checkone+'|'+o_state+',';	
    var order_id_oprstate = checkone+'|'+o_state+'|'+getStateName(o_state)+','; 
   
    document.getElementById('order_id_state').value = order_id_state; 
    document.getElementById('trade_id_state').value = trade_id_state; 
    document.getElementById('order_id_state').value = order_id_state; 
    document.getElementById('order_id_oprstate').value = order_id_oprstate; 
    document.getElementById('order_id_oprstate').value = order_id_oprstate; 

    document.getElementById('bpm_id').value ='9898';    
    document.orderForm.action='/doTradeReg.do';
    document.orderForm.submit();



}


function refund(val1,val2)
{

   var opr_state = document.getElementById('state_'+val1+'_'+val2).value; 
	 opr_state =	opr_state.replace('a',''); 
	 opr_state =	opr_state.replace('b','');
   opr_state =	opr_state.replace('c','');
   opr_state =	opr_state.replace('d','');

	 opr_state ='k'+opr_state;
 
	 var one_check = document.getElementById('check_'+val1+'_'+val2).value;	 
	 var trade_id_state = one_check+'|'+opr_state+',';	
   var trade_id_oprstate = one_check+'|k|申请退款,';
   
   var all_state=opr_state+'|';
   var onesize = document.getElementById('checksize_'+val1).value;
 
   for(var i=0;i<onesize;i++)
   {
   	   if(i!=val2)
   	   {
   	     all_state +=  document.getElementById('state_'+val1+'_'+i).value+'|'; 
   	   
   	   } 
   }  
  
    var o_state = getOneOrderState(all_state);
    var checkone = document.getElementById('checkone_'+val1).value;	             
    var order_id_state = checkone+'|'+o_state+',';	
    var order_id_oprstate = checkone+'|'+o_state+'|'+getStateName(o_state)+',';
 
   
    document.getElementById('order_id_state').value = order_id_state; 
    document.getElementById('trade_id_state').value = trade_id_state; 
    document.getElementById('order_id_state').value = order_id_state; 
    document.getElementById('order_id_oprstate').value = order_id_oprstate; 
    document.getElementById('order_id_oprstate').value = order_id_oprstate;
 
    document.getElementById('bpm_id').value ='9899';    
    document.orderForm.action='/doTradeReg.do';
    document.orderForm.submit();

}